package main.java.middle;

import java.util.Arrays;

/**
 * @Author: 郑国荣
 * @Date: 2023-08-21-17:19
 * @Description:
 */
public class Rotate {
    public static void rotate(int[] nums,int k){
        int len = nums.length;
        int index=0;
        int count =len;
        while (count>0){
            int temp = nums[(index+k)%len];
            nums[(index+k)%len] = nums[index];
            nums[index] =temp;
            index ++;
            count--;
        }
    }

    public static void main(String[] args) {
        int[] ints = {1,2,3,4,5,6,7,81,9,10};
        rotate(ints,1);
        System.out.println(Arrays.toString(ints));
//         10 转7，（10+7）%10 = 7  1+7 % 10 =8
    }
}
